<#include "/freemarker/frame.ftl"> 
<#import "/freemarker/componet/enterprise/ligeruiTree.ftl" as enterprise> 
<@frame title="" isMain=false>
<script>
component.tree.deptValidate=function(field, rules, i, options){
	var nodeCode=$("input[name='dept.code']");
	var parentNodeCode=$("input[name='parent.code']");
	if (nodeCode.val() == parentNodeCode.val()) {
		return "上级部门不能是本部门";
	}
	
	var node=$("a[nodeCode='"+nodeCode.val()+"']").closest('li');
	if(node.length>0){
		var childNode=node.find("a[nodeCode='"+parentNodeCode.val()+"']");
		if(childNode.length>0){
			return "不能选择下级部门作为上线部门";
		}
	}	
	
}
</script>
	<div class="contentcontainer">
            <div class="headings   altheading">
                <h2>部门信息管理</h2>
            </div>
            <div class="contentbox">
            <@s.form id="departmentForm" action="department" method="post" namespace="/mgr/enterprise" theme="simple">
            	<@s.hidden  name="dept.id"/>
            	<@component.textfield css="sml" cssClass="validate[required] inputbox smallbox" name="dept.name" label="部门名称"></@component.textfield>
            	<@component.textfield id="dept_code" css="sml" cssClass="validate[required]  inputbox smallbox" name="dept.code" label="部门编码"></@component.textfield>
            	<@component.popSelect cssClass="validate[funcCall[component.tree.deptValidate]] inputbox smallbox" id="sjbm" tip="点击选择" readOnly="true"
						parameter='{"title":"单位性质选择","src":"mgr/enterprise/pop_dept_tree","width":350,"height":350}'
					 name="parent.code" fieldName="parent.name" label="上级部门"></@component.popSelect>
            	<@component.textfield cssClass="inputbox" name="dept.remark" label="备注"></@component.textfield>
                <div class='clear' style='text-align: center '>
                	<@s.submit value="修改" cssClass="btn" method="modifyDept"/>
                	<@s.submit value="删除" cssClass="btn" method="delDept"/>
                </div>
            </@s.form>
	        </div>
        </div>
</@frame>